public class PrintB implements Runnable {
    private State state = new State();
    public PrintB(State state) {
        this.state = state;
    }
    @Override
    public void run(){
        while (true) {
            try {
                synchronized (state) {
                    if (!state.bRet) {
                        state.wait();
                    }
                    System.out.println("bb...");
                    state.bRet = false;
                    Thread.sleep(1000);
                    state.notify();
                }
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
